<?php
/**
 * ShopEx licence
 *
 * -------
 * -------
 */
 
class dev_command_new extends base_shell_prototype{

    var $command_app = '添加一个app';
    function command_app(){
        if(!$app_id = array_shift(func_get_args())){
            echo app::get('dev')->_("用法是： dev:new app 应用名");
            return false;
        }
        $app_dir = APP_DIR."/".$app_id;
        echo app::get('dev')->_("生成目录结构")."\n";
        @mkdir($app_dir);
        $src = APP_DIR."/dev/demo";
        echo app::get('dev')->_("拷贝文件")."\n";
        base_file::cp($src,$app_dir);
        echo app::get('dev')->_("更新配置文件")."\n";
        $replace_map = array(
            'APP_ID'=>$app_id,
            'APP_NAME'=>$app_id,
            'APP_DESC'=>app::get('dev')->_("app简短的介绍，请在").$app_dir."/app.xml".app::get('dev')->_("中修改这段信息"),
            'APP_AUTHOR'=>app::get('dev')->_("app作者的信息"),            
            'DEFAULT_CTL'=>'default',    
        );
        base_file::replace_in_file("$app_dir/app.xml",$replace_map);
        base_file::replace_in_file("$app_dir/admin/controller/default.php",$replace_map);
     	echo app::get('dev')->_("安装app")."\n";
        kernel::single('base_application_manage')->install($app_id);
    }

}

